package ru.rchervot.sanasar.client.view;

import ru.rchervot.sanasar.client.model.filters.Filter;
import ru.rchervot.sanasar.client.model.filters.FilterItemIds;

import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;

public class FilterItemIdView extends AbstractFilterView 
implements FilterItemIdPresenter.Display {

	private final TextBox textInclude = new TextBox();
	private final TextBox textExclude = new TextBox();
	
	public FilterItemIdView(String filterName,
			String filterNameHuman) {
		super(filterName, filterNameHuman);
		
		HorizontalPanel contentPanel = new HorizontalPanel();
		contentPanel.setStylePrimaryName("AbstractFilterView_pContent");
		
		contentPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		
		Label include = new Label("Include");
		Label exclude = new Label("Exclude");
		
		contentPanel.add(include);
		contentPanel.add(textInclude);
		contentPanel.add(exclude);
		contentPanel.add(textExclude);
		
		contentPanel.setCellHorizontalAlignment(include, HasHorizontalAlignment.ALIGN_RIGHT);
		contentPanel.setCellHorizontalAlignment(textInclude, HasHorizontalAlignment.ALIGN_LEFT);
		contentPanel.setCellHorizontalAlignment(exclude, HasHorizontalAlignment.ALIGN_RIGHT);
		contentPanel.setCellHorizontalAlignment(textExclude, HasHorizontalAlignment.ALIGN_LEFT);
		
		setContent(contentPanel);
		
		textInclude.setStylePrimaryName("FilterItemIdView_tInclude");
		textExclude.setStylePrimaryName("FilterItemIdView_tExclude");
		include.setStylePrimaryName("FilterItemIdView_lInclude");
		exclude.setStylePrimaryName("FilterItemIdView_lExclude");
	}

	@Override
	public void renderFilter(Filter f) {
		FilterItemIds filter = (FilterItemIds)f;
		
		textInclude.setText(filter.getItemsIDsInclude());
		textExclude.setText(filter.getItemsIDsExclude());
	}

}
